var http = require('http')
var util = require('util')
var url = require('url')
var qs = require('querystring')

var server = new http.Server()
server.on('request', (req, res) => {
    var postBody = ''
    req.on('data', (chunk) => {
        postBody += chunk
    })

    req.on('end', () => {
        console.log('request end.')
        console.log(postBody)
        postBody = qs.parse(postBody)
        console.log(postBody)
    })
    res.writeHead(200, {'Content-Type': 'application/json'})
    res.end(util.inspect(url.parse(req.url, true)))
})

server.listen(3000)
